/*
 * To change this template, choose Tools | Templates
 * and open the template 
 */
package agenda;

import agenda.contato.ContatoFactory;
import agenda.calendario.CompromissoFactory;
import framework.agendaFactory.Controle;
import javax.swing.ImageIcon;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Sergio Carlos Peres
 */
public class TelaPrincipal extends javax.swing.JFrame {

    
    //private frameworkAgenda.DesktopPane desktopPane;
    private int estiloBotoes = 0;
    private String enderecoImagens = "/framework/imagens/botoes/";
    private String[][] listaIcones = {
        {"b1.png","cadastros1.png","utilitarios1.png"},
        {"b2.png","cadastros2.png","utilitarios2.gif"},
        {"b3.png","cadastros3.png","utilitarios3.png"},
        {"b4.png","cadastros4.png","utilitarios4.png"},
        {"b5.png","cadastros5.png","utilitarios5.png"}
    };
    private Controle controle = new Controle();
    
    /**
     * Creates new form TelaPrincipal
     */
    public TelaPrincipal() {
        initComponents();
        SetLookIcon(2);
        //addDesktopPane();
        estiloBotoes = Integer.parseInt(
                framework.utilitarios.Configuracao.leConfig(
                    framework.utilitarios.Configuracao.icones[0]
                ));
        this.setExtendedState(MAXIMIZED_BOTH);
        inicializarIntenalFrame();
        alterarIcones(estiloBotoes);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuCad = new javax.swing.JMenu();
        menuItemCompromisso = new javax.swing.JMenuItem();
        menuItemContato = new javax.swing.JMenuItem();
        menuPersonalizar = new javax.swing.JMenu();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        menuItemNormal = new javax.swing.JMenuItem();
        menuItemClassico = new javax.swing.JMenuItem();
        menuItemLinux = new javax.swing.JMenuItem();
        menuItemColor = new javax.swing.JMenuItem();
        menuItemBlack = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        menuItemAcryl = new javax.swing.JMenuItem();
        menuItemLiquid = new javax.swing.JMenuItem();
        menuItemMetal = new javax.swing.JMenuItem();
        menuItemMotif = new javax.swing.JMenuItem();
        menuItemNimbus = new javax.swing.JMenuItem();
        menuItemQuaqua = new javax.swing.JMenuItem();
        menuItemSquareness = new javax.swing.JMenuItem();
        menuItemWindows = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        menuItemCalendario = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(":: Agenda :: Marshmallow-Pim 1.2");

        menuCad.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/cadastros2.png"))); // NOI18N

        menuItemCompromisso.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        menuItemCompromisso.setText("Lista de Compromisso");
        menuItemCompromisso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemCompromissoActionPerformed(evt);
            }
        });
        menuCad.add(menuItemCompromisso);

        menuItemContato.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        menuItemContato.setText("Lista de Contatos");
        menuItemContato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemContatoActionPerformed(evt);
            }
        });
        menuCad.add(menuItemContato);

        jMenuBar1.add(menuCad);

        menuPersonalizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/utilitarios2.gif"))); // NOI18N

        jMenu1.setText("Personalizar");

        jMenu2.setText("Icones");

        menuItemNormal.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_1, java.awt.event.InputEvent.ALT_MASK));
        menuItemNormal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/b1.png"))); // NOI18N
        menuItemNormal.setText("Normal");
        menuItemNormal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemNormalActionPerformed(evt);
            }
        });
        jMenu2.add(menuItemNormal);

        menuItemClassico.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_2, java.awt.event.InputEvent.ALT_MASK));
        menuItemClassico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/b2.png"))); // NOI18N
        menuItemClassico.setText("Classico");
        menuItemClassico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemClassicoActionPerformed(evt);
            }
        });
        jMenu2.add(menuItemClassico);

        menuItemLinux.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_3, java.awt.event.InputEvent.ALT_MASK));
        menuItemLinux.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/b3.png"))); // NOI18N
        menuItemLinux.setText("Linux");
        menuItemLinux.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemLinuxActionPerformed(evt);
            }
        });
        jMenu2.add(menuItemLinux);

        menuItemColor.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_4, java.awt.event.InputEvent.ALT_MASK));
        menuItemColor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/b4.png"))); // NOI18N
        menuItemColor.setText("Color");
        menuItemColor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemColorActionPerformed(evt);
            }
        });
        jMenu2.add(menuItemColor);

        menuItemBlack.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_5, java.awt.event.InputEvent.ALT_MASK));
        menuItemBlack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/b5.png"))); // NOI18N
        menuItemBlack.setText("Black");
        menuItemBlack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemBlackActionPerformed(evt);
            }
        });
        jMenu2.add(menuItemBlack);

        jMenu1.add(jMenu2);

        jMenu3.setText("Look and Feel");

        menuItemAcryl.setIcon(new javax.swing.ImageIcon(getClass().getResource("/framework/imagens/botoes/marcar_p.gif"))); // NOI18N
        menuItemAcryl.setText("Acryl");
        menuItemAcryl.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemAcrylActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemAcryl);

        menuItemLiquid.setText("Liquid");
        menuItemLiquid.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemLiquidActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemLiquid);

        menuItemMetal.setText("Metal");
        menuItemMetal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemMetalActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemMetal);

        menuItemMotif.setText("Motif");
        menuItemMotif.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemMotifActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemMotif);

        menuItemNimbus.setText("Nimbus");
        menuItemNimbus.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemNimbusActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemNimbus);

        menuItemQuaqua.setText("Quaqua");
        menuItemQuaqua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemQuaquaActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemQuaqua);

        menuItemSquareness.setText("Squareness");
        menuItemSquareness.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemSquarenessActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemSquareness);

        menuItemWindows.setText("Windows");
        menuItemWindows.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemWindowsActionPerformed(evt);
            }
        });
        jMenu3.add(menuItemWindows);

        jMenu1.add(jMenu3);

        menuPersonalizar.add(jMenu1);
        menuPersonalizar.add(jSeparator2);

        menuItemCalendario.setText("Calendario");
        menuItemCalendario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemCalendarioActionPerformed(evt);
            }
        });
        menuPersonalizar.add(menuItemCalendario);

        jMenuBar1.add(menuPersonalizar);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 900, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void menuItemCompromissoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemCompromissoActionPerformed
        if (controle.internalFrame[0].controle) {
            controle.internalFrame[0].setVisible(true);
        } else {
            desktopPane.add(controle.internalFrame[0]);
            controle.internalFrame[0].setVisible(true);
        }
    }//GEN-LAST:event_menuItemCompromissoActionPerformed

    private void menuItemCalendarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemCalendarioActionPerformed
//        Calendario c = new Calendario();
//        desktopPane.add(c);
//        c.setVisible(true);
    }//GEN-LAST:event_menuItemCalendarioActionPerformed

    private void menuItemNormalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemNormalActionPerformed
        estiloBotoes = 0;
        this.updateIconeTelaPrincipal(estiloBotoes);
        for (int i = 0; i < controle.internalFrame.length; i++) {
            controle.internalFrame[i].getToolBar().setIcones(estiloBotoes);
        }       
    }//GEN-LAST:event_menuItemNormalActionPerformed

    private void menuItemClassicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemClassicoActionPerformed
        estiloBotoes = 1;
        this.updateIconeTelaPrincipal(estiloBotoes);
        for (int i = 0; i < controle.internalFrame.length; i++) {
            controle.internalFrame[i].getToolBar().setIcones(estiloBotoes);
        } 
    }//GEN-LAST:event_menuItemClassicoActionPerformed

    private void menuItemLinuxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemLinuxActionPerformed
        estiloBotoes = 2;
        this.updateIconeTelaPrincipal(estiloBotoes);
        for (int i = 0; i < controle.internalFrame.length; i++) {
            controle.internalFrame[i].getToolBar().setIcones(estiloBotoes);
        } 
    }//GEN-LAST:event_menuItemLinuxActionPerformed

    private void menuItemColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemColorActionPerformed
        estiloBotoes = 3;
        this.updateIconeTelaPrincipal(estiloBotoes);
        for (int i = 0; i < controle.internalFrame.length; i++) {
            controle.internalFrame[i].getToolBar().setIcones(estiloBotoes);
        } 
    }//GEN-LAST:event_menuItemColorActionPerformed

    private void menuItemBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemBlackActionPerformed
        estiloBotoes = 4;
        alterarIcones(estiloBotoes);
    }//GEN-LAST:event_menuItemBlackActionPerformed

    private void menuItemContatoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemContatoActionPerformed
        if (controle.internalFrame[1].controle) {
            controle.internalFrame[1].setVisible(true);
        } else {
            desktopPane.add(controle.internalFrame[1]);
            controle.internalFrame[1].setVisible(true);
        }
    }//GEN-LAST:event_menuItemContatoActionPerformed

    private void menuItemAcrylActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemAcrylActionPerformed
        setLook(1);
    }//GEN-LAST:event_menuItemAcrylActionPerformed

    private void menuItemLiquidActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemLiquidActionPerformed
        setLook(2);
    }//GEN-LAST:event_menuItemLiquidActionPerformed

    private void menuItemMetalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemMetalActionPerformed
        setLook(3);
    }//GEN-LAST:event_menuItemMetalActionPerformed

    private void menuItemMotifActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemMotifActionPerformed
        setLook(4);
    }//GEN-LAST:event_menuItemMotifActionPerformed

    private void menuItemNimbusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemNimbusActionPerformed
        setLook(5);
    }//GEN-LAST:event_menuItemNimbusActionPerformed

    private void menuItemQuaquaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemQuaquaActionPerformed
        setLook(6);
    }//GEN-LAST:event_menuItemQuaquaActionPerformed

    private void menuItemSquarenessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemSquarenessActionPerformed
        setLook(7);
    }//GEN-LAST:event_menuItemSquarenessActionPerformed

    private void menuItemWindowsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemWindowsActionPerformed
        setLook(8);
    }//GEN-LAST:event_menuItemWindowsActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JMenu menuCad;
    private javax.swing.JMenuItem menuItemAcryl;
    private javax.swing.JMenuItem menuItemBlack;
    private javax.swing.JMenuItem menuItemCalendario;
    private javax.swing.JMenuItem menuItemClassico;
    private javax.swing.JMenuItem menuItemColor;
    private javax.swing.JMenuItem menuItemCompromisso;
    private javax.swing.JMenuItem menuItemContato;
    private javax.swing.JMenuItem menuItemLinux;
    private javax.swing.JMenuItem menuItemLiquid;
    private javax.swing.JMenuItem menuItemMetal;
    private javax.swing.JMenuItem menuItemMotif;
    private javax.swing.JMenuItem menuItemNimbus;
    private javax.swing.JMenuItem menuItemNormal;
    private javax.swing.JMenuItem menuItemQuaqua;
    private javax.swing.JMenuItem menuItemSquareness;
    private javax.swing.JMenuItem menuItemWindows;
    private javax.swing.JMenu menuPersonalizar;
    // End of variables declaration//GEN-END:variables
    
    private void alterarIcones(int estiloBotoes) {
        this.updateIconeTelaPrincipal(estiloBotoes);
        updateIconeToolBar(estiloBotoes);
    }
    
    private void updateIconeToolBar(int estiloBotoes) {
        for (int i = 0; i < controle.internalFrame.length; i++) {
            controle.internalFrame[i].getToolBar().setIcones(estiloBotoes);
        }
    }
    
    private void updateIconeTelaPrincipal(int grupoBotoes) {
        int i = 0;
        ImageIcon marcado = new javax.swing.ImageIcon(getClass().getResource(enderecoImagens + listaIcones[grupoBotoes][i++]));
       
        if (grupoBotoes == 0) this.menuItemNormal.setIcon(marcado);
        else this.menuItemNormal.setIcon(null);
        if (grupoBotoes == 1) this.menuItemClassico.setIcon(marcado);
        else this.menuItemClassico.setIcon(null);
        if (grupoBotoes == 2) this.menuItemLinux.setIcon(marcado);
        else this.menuItemLinux.setIcon(null);
        if (grupoBotoes == 3) this.menuItemColor.setIcon(marcado);
        else this.menuItemColor.setIcon(null);
        if (grupoBotoes == 4) this.menuItemBlack.setIcon(marcado);
        else this.menuItemBlack.setIcon(null);
        
        menuCad.setIcon(new javax.swing.ImageIcon(getClass().getResource(enderecoImagens + listaIcones[grupoBotoes][i++])));
        menuPersonalizar.setIcon(new javax.swing.ImageIcon(getClass().getResource(enderecoImagens + listaIcones[grupoBotoes][i++])));
        framework.utilitarios.Configuracao.escreveCinfig(
                framework.utilitarios.Configuracao.icones[0], grupoBotoes + "");
    }
    
    private void lookAndFeel(String seta_look)
    {
        try
        {
            javax.swing.UIManager.setLookAndFeel(seta_look);
            javax.swing.SwingUtilities.updateComponentTreeUI(this);
        }
        catch(ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException erro)
        {
            javax.swing.JOptionPane.showMessageDialog(null,erro);
        }
    }

    private void setLook(int i) {
        String seta_look = "";
        if (i == 1) {
            seta_look = "com.jtattoo.plaf.acryl.AcrylLookAndFeel";
            SetLookIcon(i);
        } else if (i == 2) {
            seta_look = "com.birosoft.liquid.LiquidLookAndFeel";
            SetLookIcon(i);
        } else if (i == 3) {
            seta_look = "javax.swing.plaf.metal.MetalLookAndFeel";
            SetLookIcon(i);
        } else if (i == 4) {
            seta_look = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
            SetLookIcon(i);
        } else if (i == 5) {
            seta_look = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
            SetLookIcon(i);
        } else if (i == 6) {
            seta_look = "ch.randelshofer.quaqua.QuaquaLookAndFeel";
            SetLookIcon(i);
        } else if (i == 7) {
            seta_look = "net.beeger.squareness.SquarenessLookAndFeel"; 
            SetLookIcon(i);
        } else if (i == 8) {
            seta_look = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
            SetLookIcon(i);
        } else {
            seta_look = "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel";
            SetLookIcon(4);
        }
        this.lookAndFeel(seta_look);
    }

    private void SetLookIcon(int i){
        ImageIcon marcado = new ImageIcon("/framework/imagens/botoes/marcar_p.gif");
        if (i == 1)
            this.menuItemAcryl.setIcon(marcado);
        else this.menuItemAcryl.setIcon(null);
        if (i == 2)
            this.menuItemLiquid.setIcon(marcado);
        else this.menuItemLiquid.setIcon(null);
        if (i == 3)
            this.menuItemMetal.setIcon(marcado);
        else this.menuItemMetal.setIcon(null);
        if (i == 4)
            this.menuItemMotif.setIcon(marcado);
        else this.menuItemMotif.setIcon(null);
        if (i == 5)
            this.menuItemNimbus.setIcon(marcado);
        else this.menuItemNimbus.setIcon(null);
        if (i == 6)
            this.menuItemQuaqua.setIcon(marcado);
        else this.menuItemQuaqua.setIcon(null);
        if (i == 7)
            this.menuItemSquareness.setIcon(marcado);
        else this.menuItemSquareness.setIcon(null);
        if (i == 8)
            this.menuItemWindows.setIcon(marcado);
        else this.menuItemWindows.setIcon(null);
    }
    
    // Teste da frabica
    private void inicializarIntenalFrame() {
        controle.internalFrame = new framework.agendaFactory.lib.InternalFrame[2];
        inicializarCompromissoIntermalFrame();
        inicializarContatoInternalFrame();
    }
    
    private void inicializarCompromissoIntermalFrame() {
        int i = 0;
        
        String tituloAbas[] = {"Todos os Compromissos","Adicionar Compromisso","Grupos"};
        framework.agendaFactory.AgendaFactory factory = new CompromissoFactory();
        
        factory.setParametroConexao();
        controle.internalFrame[i] = factory.criaInternalFrame(":: Lista de Compromissos ::", factory);
        controle.internalFrame[i].setStrategy(factory.getStrategy());
        java.awt.event.ActionListener listener = factory.criarActionListener(controle.internalFrame[i]);
        controle.internalFrame[i].setTabbedPane(factory.criaTabbebPane(factory.criaPanel(listener),tituloAbas));
        controle.internalFrame[i].setToolBar(factory.criaToolBar(listener));
        controle.internalFrame[i].getContentPane().setLayout(
            factory.criaLayout(
                controle.internalFrame[i].getContentPane(), 
                controle.internalFrame[i].getToolBar(), 
                controle.internalFrame[i].getTabbedPane()
            )
        );
        controle.internalFrame[i].getToolBar().visibilidade("");
        controle.internalFrame[i].ativarCamposAdicionar(false);
        controle.internalFrame[i].pack();
    }
    
    private void inicializarContatoInternalFrame() {
        int i = 1;
        
        String tituloAbas[] = {"Todos os Contatos","Adicionar Contato"};
        framework.agendaFactory.AgendaFactory factory = new ContatoFactory();
        
        factory.setParametroConexao();
        controle.internalFrame[i] = factory.criaInternalFrame(":: Lista de Contato ::", factory);
        controle.internalFrame[i].setStrategy(factory.getStrategy());
        java.awt.event.ActionListener listener = factory.criarActionListener(controle.internalFrame[i]);
        controle.internalFrame[i].setTabbedPane(factory.criaTabbebPane(factory.criaPanel(listener),tituloAbas));
        controle.internalFrame[i].setToolBar(factory.criaToolBar(listener));
        controle.internalFrame[i].getContentPane().setLayout(
            factory.criaLayout(
                controle.internalFrame[i].getContentPane(), 
                controle.internalFrame[i].getToolBar(), 
                controle.internalFrame[i].getTabbedPane()
            )
        );
        controle.internalFrame[i].getToolBar().visibilidade("");
        controle.internalFrame[i].ativarCamposAdicionar(false);
        controle.internalFrame[i].pack();
    }

    
    
}
